<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>公司盈利计算器</title>
</head>
<body>
    <div style="margin: 50px auto; text-align: center;">
        <span>
            <h3>请输入公司租金：</h3>
            <input type="text" id= "rent">
        </span>
        <span>
            <h3>请输入工资</h3>
            <input type="text" id= "wage">
        </span>
        <span>
            <h3>请输入员工数)：</h3>
            <input type="text" id= "workers">
        </span>
        <span>
            <h3>请输入生产员工数/人：</h3>
            <input type="text" id= "makeCount">
        </span>
        <span>
            <h3>请输入生产数/人均：</h3>
            <input type="text" id= "makePerson">
        </span>
        <span>
            <h3>请输入生产成本：</h3>
            <input type="text" id= "makeCost">
        </span>
        <span>
            <h3>请输入销售员工数/人：</h3>
            <input type="text" id= "salesCount">
        </span>
        <span>
            <h3>请输入销售数/人均：</h3>
            <input type="text" id= "salesPerson">
        </span>
        <span>
            <h3>请输入销售售价：</h3>
            <input type="text" id= "salesCost">
        </span>
        
        <br>
        <button id = "cal">计算</button>
        <span>
            <h3>最大利润</h3>
            <input type="text" id= "earn"></input>
            <!-- <h3>计算结果</h3>
            <input type="text" id= "wage"></input>
            <h3>年薪</h3>
            <input type="text" id= "year"></input> -->
        </span>
    </div>
    <script>
        function $(id) {
            return document.getElementById(id);
        }
        
        let rent = $("rent");
        let wage = $("wage");
        let year = $("workers");
        let salesCount = $("salesCount");
        let salesPerson = $("salesPerson");
        let salesCost = $("salesCost");
        let makeCount = $("makeCount");
        let makePerson = $("makePerson");
        let makeCost = $("makeCost");
        let btn = $("cal");

        btn.addEventListener("click",() => {
            let cost = rent.value + (makeCount.value + makeCount.value) * wage.value + (makeCount.value * makePerson.value * makeCost.value);
            let earn = (salesCost.value * salesCount.value * salesPerson.value);
            this.earn.value = earn - cost;

        }, false);
    </script>
</body>
</html>